using UnityEngine;
using System.Collections;

public class RotatePlayer_Camera : MonoBehaviour {
	
	public Transform player;
	public Transform _camera;
	
	// Use this for initialization
	void Start () {
		
		player = GameObject.FindGameObjectWithTag("Corpo").transform;
		_camera = GameObject.FindGameObjectWithTag("MainCamera").transform;
	}
	
	// Update is called once per frame
	void Update () {
		
		
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit  hit;
		
		if(Physics.Raycast(ray, out hit, 100))
		{}
		
		player.transform.LookAt(new Vector3(hit.point.x, player.transform.position.y, hit.point.z));
		
		
		MoveCamera();
		
	}
	
	void MoveCamera(){
		
		Vector3 cameraPositionDefault = new Vector3(player.position.x, player.position.y + 10, player.position.z - 10);
		Vector3 playerPositionDefault = new Vector3(transform.position.x, transform.position.y - 10, transform.position.z + 10);
		Vector3 cameraPositionTemp = new Vector3(0, 0, 0);
		
		/*if(player.position != playerPositionDefault)
		{
			cameraPositionTemp = Vector3.Lerp(transform.position, cameraPositionDefault, Time.deltaTime * 2);
		}*/
		
		transform.position = cameraPositionDefault;
	}
}
